home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC18AccessPriv / UWindow.c < prev   
Encoding:
C/C++ Source or Header  |  1990-05-25  |  23.0 KB  |  679 lines  |  [04] ASCII Text (0x0000)

  1. /***********************************************************************
  2. *
  3. * AccessPriv uWindow.c
  4. *
  5. * Copyright (c)
  6. * Apple Computer, Inc.  1989-1990
  7. * All Rights Reserved.
  8. *
  9. * Developer Technical Support Apple II Sample Code
  10. *
  11. * This file contains the code which implements  
  12. * windows in the AccessPriv program.
  13. *
  14. ***********************************************************************/
  15.  
  16. #include <types.h>
  17. #include <quickdraw.h>
  18. #include <window.h>
  19. #include <math.h>
  20. #include <control.h>
  21. #include <lineedit.h>
  22. #include <stdfile.h>
  23. #include <GSOS.h>
  24. #include <dialog.h>
  25. #include <memory.h>
  26. #include <AppleShare.h>
  27.  
  28. #include "ap.h"
  29.  
  30. extern unsigned int         staggerCount, suppressErrors;
  31. extern GrafPortPtr          windowList[SHORTINDEX];
  32. extern handle               PrivCtrlHndls[7][3];
  33. extern ptr                  mysubsttext[9];
  34. extern GetAccessRightsRec   curaccessprivs;
  35. extern SetAccessRightsRec   newaccessprivs;
  36.  
  37.  
  38. extern GSString32Ptr    DirEntryNamePtr;
  39. extern DirEntryRecGS    myGetDirEntryRec;
  40.  
  41. extern UserInfoRec      ASuserinfoRec;
  42.  
  43. extern GetPrivilegesRec ASgetprivsRec;
  44. extern SetPrivilegesRec ASsetprivsRec;
  45. extern ResultBuf255     ownernametoget, ownernametoset;
  46. extern ResultBuf255     groupnametoget, groupnametoset;
  47. extern ResultBuf255     usernametoget, usergroupnametoget, SFpathresult;
  48. extern GSString255      foldertogetsetprivsof, volname;
  49.  
  50. extern GSString255Ptr   pathstrPtr;
  51. extern char             hastheseprivs[60],blanks[255];
  52.  
  53. extern byte             power2[3];
  54. extern int              userisowner;
  55.  
  56. extern multiReplyRecord myReply;
  57.  
  58.  
  59. extern int              _toolErr;
  60.  
  61. #define MainWindowID    0x1000L
  62. #define rWindParam1     0x800E
  63.  
  64. /************************************************************************
  65. *
  66. * drawThisWindow
  67. *
  68. * This routine draws the contents of all the windows.
  69. *
  70. ************************************************************************/
  71. void    drawThisWindow()
  72. {
  73.     DrawControls(GetPort());
  74. }
  75.  
  76. /************************************************************************
  77. *
  78. * doCloseTop
  79. *
  80. * This routine closes the topmost window.  We do a little work to
  81. * prevent the main window from being closed.
  82. *
  83. ************************************************************************/
  84. void    doCloseTop()
  85. {
  86.     unsigned int    k;
  87.     GrafPortPtr     tempWin;
  88.  
  89.     tempWin = FrontWindow();
  90.         
  91.     /* Find the window entry, close the window, and zero the entry */
  92.     /* start the count at 1 since we never close the main window */
  93.     for (k = 1; k < NumWindows; k++) {
  94.         if (tempWin == windowList[k]) {
  95.             CloseWindow(tempWin);
  96.             windowList[k] = NULL;
  97.             break;
  98.         }
  99.     }
  100. }
  101.  
  102. /***********************************************************************
  103. *
  104. * openThisWindow
  105. *
  106. * This routine either opens the specified window or brings it to the top
  107. * if it is already open.
  108. *
  109. * If it is not open, we open it with NewWindow2 invisibly, adjust the window's
  110. * location and then show and select the window.
  111. *
  112. ************************************************************************/
  113. void            openThisWindow(ctlid)
  114. unsigned int    ctlid;
  115. {
  116.     GrafPortPtr     wptr;
  117.  
  118.     if (!(wptr = windowList[ctlid])) {
  119.         windowList[ctlid] = wptr =
  120.             NewWindow2(NULL, NULL, drawThisWindow, NULL, 2, ctlid+MainWindowID,
  121.                        rWindParam1);
  122.         if (ctlid < Prog1ID) {
  123.             MoveWindow (50 + 8 * staggerCount, 50 + 8 * staggerCount, wptr);
  124.             staggerCount++;
  125.             staggerCount &= 0x0F;
  126.         }
  127.         ShowWindow(wptr);
  128.         SelectWindow(wptr);             
  129.     }
  130.     else SelectWindow(wptr);
  131. }
  132.     
  133. /*************************************************************************
  134. *
  135. * DefaultErrorWindow
  136. *
  137. * if _toolErr not zero, calls Error Window with default params
  138. * Special case:  If suppressErrors is set, then don't show
  139. * OS errors.
  140. *
  141. **************************************************************************/
  142. void CheckToolOrSysError()
  143. {
  144.     unsigned int    err;
  145.  
  146.     err = _toolErr;
  147.     if ((suppressErrors) && (err < 256)) err = 0;
  148.  
  149.     if (err) ErrorWindow(0, NULL, err);
  150. }
  151.  
  152. /*************************************************************************
  153. *
  154. * MySFPfilter
  155. *
  156. * determines which files will be displayed, beyond selection in typelist
  157. *
  158. **************************************************************************/
  159. pascal int MySFfilter(myDirEntryRecPtr)
  160. DirEntryRecPtrGS myDirEntryRecPtr;
  161. {
  162.     GSString32Ptr myGSStringPtr;
  163.     GSString32    myGSString;
  164.     int entrylen;
  165.     unsigned int flag, dbr;  /* result, data bank register value */
  166.     
  167.     dbr = SaveDB();                 /* make the data bank reg.   */
  168.                                     /* point to globals, save it */
  169.  
  170.                                     /* get the entire dir entry record */
  171.     myGetDirEntryRec.pCount = 17;
  172.     myGetDirEntryRec.refNum = myDirEntryRecPtr->refNum;
  173.     myGetDirEntryRec.flags = myDirEntryRecPtr->flags;
  174.     myGetDirEntryRec.base = 1;
  175.     myGetDirEntryRec.displacement = 0;
  176.     myGetDirEntryRec.name = myDirEntryRecPtr->name;
  177.  
  178.     GetDirEntryGS(&myGetDirEntryRec);
  179.  
  180.     flag = noDisplay;
  181.     if ((myGetDirEntryRec.fileType == 0x000f) &&
  182.         (myGetDirEntryRec.fileSysID == appleShareFSID)) flag = displaySelect;
  183.     RestoreDB(dbr);                 /* restore data bank reg. for return */
  184.                                     /* to toolbox */
  185.     return(flag);
  186. }
  187.  
  188. /*************************************************************************
  189. *
  190. * ChooseFolder
  191. *
  192. * presents user with dialog to select folder to show/set privileges of
  193. *
  194. **************************************************************************/
  195. void    ChooseFolder()
  196. {
  197.     int* namelenptr;
  198.     SFMultiReplyNamesRec2Ptr myNamesRecPtr;
  199.     static char prompt[] = "\pPick (accept) folder to examine privileges of.";
  200.     ExpandPathRecGS myexpandpathrec;
  201.     
  202.                                          /* select folder type, any aux type */
  203.     static SFTypeList2 mySFtypelist = {
  204.     1,
  205.     0x8000,
  206.     0x000f,
  207.     0L};
  208.  
  209.     (SFpathresult.bufString).length = 0;
  210.     *((SFpathresult.bufString).text) = 0;
  211.     SFMultiGet2(             /* user selection of folder to get/set privs of */
  212.         120, 53,
  213.         refIsPointer,
  214.         prompt,
  215.         MySFfilter,         
  216.         &mySFtypelist,          
  217.         &myReply
  218.     );
  219.     if (_toolErr) {
  220.         CheckToolOrSysError();
  221.         pathstrPtr->text[0] = (char) 0;
  222.         pathstrPtr->length = 0;
  223.         return;
  224.     }
  225.     
  226.     if (myReply.good) {
  227.                                                     /* use 1st name returned */
  228.         HLock(myReply.namesHandle);
  229.         myNamesRecPtr =
  230.             (SFMultiReplyNamesRec2Ptr) ((char *) (*myReply.namesHandle) + 2);           
  231.         p2cstr(&(myNamesRecPtr->namestrlen));                                       
  232.         strcpy(
  233.             foldertogetsetprivsof.text,(char *)&(myNamesRecPtr->namestrlen));
  234.         foldertogetsetprivsof.length =
  235.             strlen((char *) (foldertogetsetprivsof.text));
  236.         DisposeHandle(myReply.namesHandle);
  237.                                                   /* multiget2 sets prefix 8 */
  238.                                                   /* expand to full path     */
  239.         myexpandpathrec.pCount = 3;
  240.         myexpandpathrec.inputPath = &foldertogetsetprivsof;
  241.         myexpandpathrec.outputPath = &SFpathresult;
  242.         myexpandpathrec.flags = 0;
  243.         ExpandPathGS(&myexpandpathrec);
  244.         CheckToolOrSysError();
  245.     }
  246.     else suppressErrors = 1;
  247. }
  248.  
  249. /**********************************************************************
  250. *
  251. * displayfoldervolumeanduser
  252. *
  253. * sets display of name user is logged in as, folder selected, and volume
  254. *
  255. **********************************************************************/
  256. void displayfoldervolumeanduser()
  257. {
  258.     DevNumRecGS myDevNumRecPB;
  259.     GSString32Ptr myGSStringPtr;
  260.     int totalpathlen;
  261.     char *acolon = ":";
  262.     int pathlessvolstart;
  263.     int volstrlen;
  264.     int nextcolon;
  265.     
  266.     if (myReply.good)
  267.     {
  268.     volstrlen = strcspn(&(pathstrPtr->text[1]),acolon) + 1;
  269.     volname.length = volstrlen;
  270.     strncpy(volname.text,pathstrPtr->text,volstrlen); /* make vol string */
  271.     volname.text[volstrlen] = (char) 0;
  272.     myGSStringPtr = (GSString32Ptr) &(ASuserinfoRec.userName->bufString);
  273.     myDevNumRecPB.pCount = 2;                    /* set up param block for & */
  274.     myDevNumRecPB.devName = &volname;        /* issue GetDevNumber call  */
  275.     GetDevNumberGS(&myDevNumRecPB);
  276.     CheckToolOrSysError();
  277.     ASuserinfoRec.deviceNum = myDevNumRecPB.devNum;  /* devNum from UserInfo  */
  278.     FSTSpecific( &ASuserinfoRec);
  279.     if (_toolErr) {
  280.         myGSStringPtr->length = 0;
  281.         CheckToolOrSysError();
  282.     }
  283.     myGSStringPtr->text[myGSStringPtr->length] = (char) 0;   /* term. string */
  284.     totalpathlen = pathstrPtr->length;
  285.     pathstrPtr->text[totalpathlen] = (char) 0;     /* term. path string      */
  286.     if ((totalpathlen - volstrlen) > 32) {         /* does partial path fit? */
  287.         pathlessvolstart = totalpathlen - 32;      /* no- not room in window */
  288.                                                    /* use end part of it     */
  289.         nextcolon = strcspn(&(pathstrPtr->text[pathlessvolstart]),acolon);
  290.         pathlessvolstart = pathlessvolstart + nextcolon - 1;    /* str index */
  291.         pathstrPtr->text[pathlessvolstart] = '.';
  292.         pathstrPtr->text[pathlessvolstart+1] = '.';
  293.     }
  294.     else pathlessvolstart = volstrlen + 1;          /* yes- alt. str index   */
  295.                                                     /* display partial path  */
  296.     mysubsttext[0] = &(pathstrPtr->text[pathlessvolstart]);
  297.     }
  298.     else {                                          /* make these strings null */
  299.     volname.length = 0;
  300.     volname.text[0] = 0;
  301.     volname.text[1] = 0;
  302.     mysubsttext[0] = volname.text;
  303.     (usernametoget.bufString).length = 0;
  304.     (usernametoget.bufString).text[0] = 0;
  305.  
  306.     }
  307. }
  308.  
  309. /*************************************************************************
  310. *
  311. * newownerorgroup
  312. *
  313. * Sets owner or group name for the file/folder
  314. *
  315. * inputs:  pointer to GS/OS result buffer to store name of owner/group,
  316. *          handle to LineEdit control containing name of owner/group
  317. *
  318. ************************************************************************/
  319. void newownerorgroup(myRBPtr,myCtlRecHndl)
  320.     ResultBuf255Ptr myRBPtr;
  321.     CtlRecHndl myCtlRecHndl;
  322.     
  323. {
  324.     GSString255Ptr myGSStringPtr;
  325.     LERecHndl myLERecHndl;
  326.     Handle myleLineHandle;
  327.     int LElen;
  328.     char *mycharptr;
  329.     
  330.     myLERecHndl = (LERecHndl) ((*myCtlRecHndl)->ctlData); /* hndl to LE rec  */
  331.     myleLineHandle = LEGetTextHand(myLERecHndl);          /* hndl to its text*/
  332.     LElen = LEGetTextLen(myLERecHndl);                    /* length of text  */
  333.     myGSStringPtr = (GSString255Ptr) &(myRBPtr->bufString); /* str to copy to*/
  334.     strncpy(myGSStringPtr->text,(*myleLineHandle),LElen);   /* copy LE text  */
  335.     mycharptr = ((char *) (myGSStringPtr->text)) + LElen;   /* ptr to term.  */
  336.     (*mycharptr) = 0;                                       /* term. CString */
  337.     myGSStringPtr->length = LElen;                          /* set str len   */
  338.  
  339. }
  340.  
  341. /**************************************************************************
  342. *
  343. * dispownerorgroup
  344. *
  345. * sets display of owner/group name for the file/folder
  346. *
  347. * inputs:  pointer to GS/OS result buffer containing name of owner/group,
  348. *          handle to LineEdit control to edit and display it in
  349. *
  350. *************************************************************************/
  351. void dispownerorgroup(myRBPtr,myCtlRecHndl)
  352.     ResultBuf255Ptr myRBPtr;
  353.     CtlRecHndl myCtlRecHndl;
  354. {
  355.     GSString255Ptr myGSStringPtr;
  356.     LERecHndl myLERecHndl;
  357.     
  358.     myGSStringPtr= (GSString255Ptr) &(myRBPtr->bufString); /* ptr to name str*/
  359.     myLERecHndl= (LERecHndl) ((*myCtlRecHndl)->ctlData);   /* hndl to LE rec */
  360.     LESetText(myGSStringPtr->text,myGSStringPtr->length,myLERecHndl);
  361.     myGSStringPtr->text[myGSStringPtr->length] = (char) 0;
  362.     InvalRect(&((*myLERecHndl)->leViewRect));              /* coerce display */
  363. }
  364.  
  365. /**************************************************************************
  366. *
  367. * displayuserprivs
  368. *
  369. * decodes UserSummary field of access privs, sets display of list of them
  370. *
  371. **************************************************************************/
  372. void displayuserprivs()
  373. {
  374.     int i;
  375.     static char seefolderstr[] = "See folders";
  376.     static char seefilerstr[] = "See files";
  377.     static char makechangesstr[] = "Make changes";
  378.     static char comma[] = ", ";
  379.     static char none[] = "none";
  380.     boolean otheritem;
  381.     
  382.     otheritem = false;                 /* track whether comma will be needed */
  383.     /* hastheseprivs = privs; */
  384.     (*hastheseprivs) = (char) 0;
  385.     for (i = 0; i < 3; i++)            /* loop through each of 3 bits        */
  386.     {
  387.                                        /* does user have selected privs?     */
  388.          if ((curaccessprivs.userSummary & power2[i]) != 0)
  389.          switch(i)
  390.         {
  391.             case 0: strcat(hastheseprivs,seefolderstr); /* has seefolder priv*/
  392.                     otheritem = true;
  393.                     break;
  394.             case 1: if (otheritem) strcat(hastheseprivs,comma); /* add comma?*/
  395.                     strcat(hastheseprivs,seefilerstr);   /* has seefile priv */
  396.                     otheritem = true;
  397.                     break;
  398.             case 2: if (otheritem) strcat(hastheseprivs,comma); /* add comma?*/
  399.                                                  /* has priv to make changes */
  400.                     strcat(hastheseprivs,makechangesstr);
  401.                     break;
  402.         }
  403.     }
  404.     if (*hastheseprivs == (char) 0) strcpy(hastheseprivs,none);
  405. }
  406.  
  407. /************************************************************************
  408. *
  409. * setlockedctrl
  410. *
  411. * sets locked check box, or not, depending if file/folder is locked
  412. *
  413. *************************************************************************/
  414. void setlockedctrl()
  415. {
  416.     FileInfoRecGS myFileInfoRecPB;
  417.     int ifitslocked;
  418.     
  419.     myFileInfoRecPB.pCount = 3;                   /* set param block for and */
  420.     myFileInfoRecPB.pathname = &foldertogetsetprivsof;  /* issue GetFileInfo */
  421.     GetFileInfoGS(&myFileInfoRecPB);
  422.     if (_toolErr) CheckToolOrSysError();
  423.     else {
  424.         if ((myFileInfoRecPB.access & (renameEnable | destroyEnable)) == 0) 
  425.             ifitslocked = 1;
  426.         else
  427.             ifitslocked = 0;
  428.         SetCtlValue(ifitslocked,PrivCtrlHndls[4][0]); /* set ctl accordingly */
  429.     }
  430. }
  431.  
  432. /***********************************************************************
  433. *
  434. * NewLockedSetting
  435. *
  436. * sets locked attributes of file/folder depending if user checked it locked
  437. *
  438. ************************************************************************/
  439. void NewLockedSetting()
  440. {
  441.     FileInfoRecGS myFileInfoRec;
  442.     int ifitslocked;
  443.     
  444.     ifitslocked= (Word) GetCtlValue(PrivCtrlHndls[4][0]); /* inspect checkbox*/
  445.     myFileInfoRec.pCount = 2;                        /* set param block for  */
  446.     myFileInfoRec.pathname = &foldertogetsetprivsof; /* and issue GetFileInfo*/
  447.     GetFileInfoGS(&myFileInfoRec);
  448.     if (_toolErr) CheckToolOrSysError();
  449.     else {
  450.         if (ifitslocked == 0)
  451.             myFileInfoRec.access =
  452.                 myFileInfoRec.access | renameEnable | destroyEnable;
  453.         else
  454.             myFileInfoRec.access = (myFileInfoRec.access & 0xff3f);
  455.                                                    /* call SetFileInfo with  */
  456.                                                    /* parms returned, access */
  457.                                                    /* modified per check box */
  458.         SetFileInfoGS(&myFileInfoRec);  
  459.         CheckToolOrSysError();
  460.     }
  461. }
  462.  
  463. /************************************************************************
  464. *
  465. * CanMakeChanges
  466. *
  467. * redisplays privileges check box and text which may have been hidden
  468. *
  469. *************************************************************************/
  470. void CanMakeChanges()
  471. {
  472.     int i, j;
  473.     
  474.     for (i = 0; i < 3; i++)              /* show the access priv check boxes */
  475.     {
  476.         for (j = 0; j < 3; j++)
  477.         {
  478.             ShowControl(PrivCtrlHndls[i][j]);
  479.         }
  480.     }
  481.     ShowControl(PrivCtrlHndls[5][1]);    /* show the corresp. static text    */
  482.     HideControl(PrivCtrlHndls[6][1]);    /* don't show the static text that  */
  483.     HideControl(PrivCtrlHndls[6][2]);    /* subs for the LineEdit text       */
  484.     ShowControl(PrivCtrlHndls[4][1]);    /* show the LineEdit text and       */
  485.     ShowControl(PrivCtrlHndls[4][2]);
  486.     HiliteControl(noHilite,PrivCtrlHndls[4][0]); /* display locked check box */
  487.     HiliteControl(noHilite,PrivCtrlHndls[3][0]); /* undo button, and         */
  488.     HiliteControl(noHilite,PrivCtrlHndls[3][1]); /* save button, undimmed    */
  489. }
  490.  
  491. /*************************************************************************
  492. *
  493. * CannotMakeChanges
  494. *
  495. * hides privileges check boxes and text if user is not owner of file/folder
  496. *
  497. **************************************************************************/
  498. void CannotMakeChanges()
  499. {
  500.     int i, j;
  501.  
  502.     for (i = 0; i < 3; i++)            /* hide the access priv check boxes */
  503.     {
  504.         for (j = 0; j < 3; j++)
  505.         {
  506.             HideControl(PrivCtrlHndls[i][j]);
  507.         }
  508.     }
  509.     HideControl(PrivCtrlHndls[5][1]); /* hide the corresp. static text       */
  510.     HideControl(PrivCtrlHndls[4][1]); /* don't show the the LineEdit boxes   */
  511.     HideControl(PrivCtrlHndls[4][2]);                       
  512.     ShowControl(PrivCtrlHndls[6][1]); /* show the static text that subs      */
  513.     ShowControl(PrivCtrlHndls[6][2]); /* for the LineEdit text               */
  514.                                       /* dim display of the locked check box */
  515.     HiliteControl(inactiveHilite,PrivCtrlHndls[4][0]);
  516.     HiliteControl(inactiveHilite,PrivCtrlHndls[3][0]);   /* undo button, and */
  517.     HiliteControl(inactiveHilite,PrivCtrlHndls[3][1]);   /* save button      */
  518. }
  519.  
  520. /************************************************************************
  521. *
  522. * CurrentPrivs
  523. *
  524. * displays information about user access for the file including privileges,
  525. * check boxes to set the privileges, owner name, group name, name user is
  526. * logged in as, etc.
  527. *
  528. *************************************************************************/
  529. void CurrentPrivs()
  530. {
  531.  
  532.     int privbit, i, j;
  533.     LERecHndl myLERecHndl;
  534.     GrafPortPtr  keepPort, topPort;
  535.     
  536.     FSTSpecific( &ASgetprivsRec);                  /* get the privs */
  537.     if ((_toolErr) || !(myReply.good)) {
  538.         CheckToolOrSysError();
  539.                                   /* if error occurs, invalidate return vals */
  540.         (ownernametoget.bufString).length = 0;
  541.         (ownernametoget.bufString).text[0] = (char) 0;
  542.         (groupnametoget.bufString).length = 0;
  543.         (groupnametoget.bufString).text[0] = (char) 0;
  544.         curaccessprivs = (GetAccessRightsRec) 0L;
  545.     }
  546.     else curaccessprivs = ASgetprivsRec.accessRights;       /* else save 'em */
  547.     userisowner = curaccessprivs.userSummary & 0x80;
  548.     
  549.     keepPort = GetPort();
  550.     topPort = FrontWindow();
  551.     SetPort(topPort);
  552.     dispownerorgroup(ASgetprivsRec.ownerName,(CtlRecHndl)PrivCtrlHndls[4][1]);
  553.     dispownerorgroup(ASgetprivsRec.groupName,(CtlRecHndl)PrivCtrlHndls[4][2]);
  554.     setlockedctrl();
  555.     displayfoldervolumeanduser();
  556.     displayuserprivs();
  557.     if (userisowner)                                       /* is user owner? */
  558.     {
  559.         CanMakeChanges();              /* display user setable priv controls */
  560.         for (i = 0; i < 3; i++)        /* set priv check boxes               */
  561.         {
  562.             for (j = 0; j < 3; j++)
  563.             {
  564.                  switch(i)
  565.                 {
  566.                     case 0: privbit = (int)(curaccessprivs.world & power2[j]);
  567.                             break;
  568.                     case 1: privbit = (int)(curaccessprivs.group & power2[j]);
  569.                             break;
  570.                     case 2: privbit = (int)(curaccessprivs.owner & power2[j]);
  571.                             break;
  572.                 }
  573.             SetCtlValue(privbit,PrivCtrlHndls[i][j]);
  574.             }
  575.         }
  576.     }
  577.     else {
  578.     CannotMakeChanges();         /* display priv controls , not user setable */
  579.     }
  580.     InvalRect(&(*topPort).portRect);           /* and cause it to be redrawn */
  581.     SetPort(keepPort);
  582. }
  583.  
  584. /*********************************************************************
  585. *
  586. * NewPrivs
  587. *
  588. * sets information about user access for the file including privileges, owner
  589. * name, group name, and whether file/folder is locked
  590. *
  591. ***********************************************************************/
  592. void NewPrivs()
  593. {
  594.  
  595.     int privbit, i, j,k;
  596.  
  597.     newaccessprivs.reserved = (Byte) 0;         /* set privs per check boxes */
  598.     newaccessprivs.world = (Byte) (curaccessprivs.world & 0xf8);
  599.     newaccessprivs.group = (Byte) (curaccessprivs.group & 0xf8);
  600.     newaccessprivs.owner = (Byte) (curaccessprivs.owner & 0xf8);
  601.     for (i = 0; i < 3; i++)
  602.     {
  603.         for (j = 0; j < 3; j++)
  604.         {
  605.              privbit = (Word) GetCtlValue(PrivCtrlHndls[i][j]);
  606.              if (privbit != 0)
  607.              switch(i)
  608.             {
  609.                 case 0: newaccessprivs.world =
  610.                             (Byte) (newaccessprivs.world | power2[j]);
  611.                         break;
  612.                 case 1: newaccessprivs.group =
  613.                             (Byte) (newaccessprivs.group | power2[j]);
  614.                         break;
  615.                 case 2: newaccessprivs.owner =
  616.                             (Byte) (newaccessprivs.owner | power2[j]);
  617.                         break;
  618.             }
  619.         }
  620.     }
  621.     ASsetprivsRec.accessRights = newaccessprivs; /* setup parm block & privs */
  622.     
  623.     newownerorgroup(ASsetprivsRec.ownerName,(CtlRecHndl) PrivCtrlHndls[4][1]);
  624.     newownerorgroup(ASsetprivsRec.groupName,(CtlRecHndl) PrivCtrlHndls[4][2]);
  625.     FSTSpecific( &ASsetprivsRec);
  626.     CheckToolOrSysError();
  627.     NewLockedSetting();                     /* set locked bits per check box */
  628.     CurrentPrivs();                       /* request and redisplay new privs */
  629. }
  630.  
  631. /**********************************************************************
  632. *
  633. * setupCtrls
  634. *
  635. * Sets up handles to controls for use through out the program.
  636. *
  637. ***********************************************************************/
  638. void    setupCtrls()
  639. {
  640.     int i, j;
  641.     unsigned long thisCtrlID;
  642.     
  643.     for (i = 0; i < 7; i++) /* loop through control handles, place into array*/
  644.     {
  645.         for (j = 0; j < 3; j++)
  646.         {
  647.                                           /* CheckFolderAllSee is 1st handle */
  648.             thisCtrlID = i*3 + j + CheckFolderAllSee;           
  649.             PrivCtrlHndls[i][j] =
  650.                 (handle) GetCtlHandleFromID(windowList[0],thisCtrlID);
  651.         }
  652.     }
  653.  
  654.     SetCtlParamPtr(mysubsttext);    /* establish pointers for subst. text    */
  655.     CheckToolOrSysError();
  656.                                     /* get 1st folder request and show privs */
  657.     ChooseFolder();
  658.     CurrentPrivs();
  659. }
  660.  
  661. /**********************************************************************
  662. *
  663. * setupWindows
  664. *
  665. * Sets up windowList record for use through out the program.
  666. *
  667. ***********************************************************************/
  668. void    setupWindows()
  669. {
  670.     unsigned int    k;
  671.  
  672.     /* Zero out the entries in the window list. */
  673.     for (k = 0; k < NumWindows; k++) windowList[k] = NULL;
  674.  
  675.     /* Open the main window */
  676.     windowList[0] = NewWindow2(NULL, NULL, drawThisWindow, NULL, 2,
  677.         MainWindowID, rWindParam1);
  678. }
  679.